﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layuimini/css/public.css" rel="stylesheet" />
    <style>


    </style>
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <fieldset class="table-search-fieldset">
                <legend>搜索信息</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <form class="layui-form layui-form-pane" action="">
                        <input type="hidden" id="type" value="@ViewBag.TypeID" />
                        <input type="hidden" id="BillNameID" value="@ViewBag.BillNameID" />
                        <input type="hidden" id="back" value="@ViewBag.Back" />
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">关键字</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="name" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                                <button type="submit" class="layui-btn layui-btn-normal" lay-submit lay-filter="sub"> 选 择</button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>
            <script type="text/html" id="toolbarDemo">
                @*<div class="layui-btn-container">
                    <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
                    <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>
                    <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="import"> 导入 </button>
                </div>*@
            </script>
            <table class="layui-hide" id="table" lay-filter="currentTableFilter"></table>
            <script type="text/html" id="currentTableBar">
                @*<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
                <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>*@
            </script>
        </div>
    </div>
    <script src="~/layui/layui.js"></script>
    <script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#table',
            method:'post',
            url: '@Url.Action("GoodsSelectListAsync", "BasicInfo")',
            request: {
                pageName: 'PageIndex' //页码的参数名称，默认：page
               ,limitName: 'PageSize' //每页数据量的参数名，默认：limit
            },
            where: {
                Search: $('#name').val(),
                TypeID: $('#type').val(),
                State: 1,
                BillNameID: $('#BillNameID').val(),
                Type: $('#back').val(),
            },
        toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print'],
            cols: [[
                { type: "radio", width: 50 },
                { type: 'numbers', title: '序号', width: 50 },
                { field: 'ID', title: 'ID', width: 100, hide: true },
                //{ field: 'Code', title: '编号' },
                { field: 'Name', title: '名称' },
                { field: 'Model', title: '型号' },
            ]],
            limits: [10, 20, 30, 50, 100, 100000000],
            limit: 20,
            page: false,
            //skin: 'line',
            //totalRow: true,
            height: 'full-170',
            //size:'sm',
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            RefreshTable();
            return false;
        });
        form.on('submit(sub)', function (data) {
            //执行搜索重载
            var checkStatus = table.checkStatus('table');
            if (checkStatus.data.length == 0) {
                layer.msg('没有选择任何零件！', { icon: 5, time: 2000 });
                return false;
            }
            var data = checkStatus.data[0];

            parent.selectgoods(data.ID, data.Code, data.Name,data.Model,$('#back').val()); //这是父页面函数
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
            return false;
        });



        function RefreshTable() {
            table.reload('table', {
                where: {
                    Search: $('#name').val(),
                    TypeID: $('#type').val(),
                    State: 1,
                    BillNameID: $('#BillNameID').val(),
                    Type: $('#back').val(),
                }
            }, 'data');

        }
    });
    </script>
</body>
</html>